package com.bytecodezz.app.learn3

class NativeRenderer {
    companion object {
        init {
            //相当于java中的静态块 static{}
            System.loadLibrary("native-draw")
        }
    }

    fun initRenderer(): Long {
        return nativeInitRenderer()
    }

    fun surfaceChange(ptr: Long, width: Int, height: Int) {
        return nativeSurfaceChange(ptr, width, height)
    }

    fun draw(ptr: Long) {
        return nativeDraw(ptr)
    }

    fun switchFilterAlpha(ptr: Long, isOpen: Boolean) {
        nativeFilterAlphaSwitch(ptr, isOpen)
    }

    fun setAlphaFilterValue(ptr: Long, value: Float) {
        nativeFilterAlphaValue(ptr, value)
    }

    //初始化
    private external fun nativeInitRenderer(): Long

    //创建
    private external fun nativeSurfaceChange(ptr: Long, width: Int, height: Int)

    //绘制
    private external fun nativeDraw(ptr: Long)

    //创建透明度过滤器
    private external fun nativeInitFilterAlpha(): Long

    //透明度过滤器开关
    private external fun nativeFilterAlphaSwitch(ptr: Long, isOpen: Boolean)

    //调节透明度过滤器
    private external fun nativeFilterAlphaValue(ptr: Long, value: Float)

}